/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.portalcenter.model.entity;

import cn.hallele.mc.sdk.portalcenter.common.enums.MenuTypeEnum;
import jakarta.persistence.*;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * MenuEntity
 *
 * @author anle5
 * @since 2024/5/30 23:54
 */
@Getter
@Setter
@Entity
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "pc_menu")
public class MenuEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 3228054026740063722L;

    /**
     * 身份唯一标识
     * 生成策略: 从表key_generator中读取
     * name: TableGenerator唯一标识
     * pkColumnName：生成策略所对应键值的名称
     * pkColumnValue：键当前所生成的值，它的值将会随着每次创建累加
     * initialValue: 初始值
     * allocationSize: 递增至
     */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "MenuEntity")
    @TableGenerator(name = "MenuEntity",
            table = "key_generator",
            pkColumnName = "gen_name",
            valueColumnName = "gen_value",
            pkColumnValue = "pc_menu",
            initialValue = 1,
            allocationSize = 1
    )
    @Column(name = "id")
    private Long id;

    /**
     * 父菜单id
     */
    @Column(name = "parent_id")
    private Long parentId;

    /**
     * 菜单名
     */
    @Column(name = "title")
    private String title;

    /**
     * 路由名
     */
    @Column(name = "name")
    private String name;

    /**
     * 菜单类型
     */
    @Column(name = "type")
    private MenuTypeEnum type;

    /**
     * 菜单路径
     */
    @Column(name = "path")
    private String path;

    /**
     * 组件
     */
    @Column(name = "component")
    private String component;

    /**
     * 权限标识
     */
    @Column(name = "perm")
    private String perm;

    /**
     * 显示状态
     */
    @Column(name = "hide")
    private String hide;

    /**
     * 排序
     */
    @Column(name = "sort")
    private Integer sort;

    /**
     * 菜单图标
     */
    @Column(name = "icon")
    private String icon;

    /**
     * 跳转路径
     */
    @Column(name = "redirect")
    private String redirect;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 【目录】只有一个子路由是否始终显示
     */
    @Column(name = "always_show")
    private String alwaysShow;

    /**
     * 【菜单】是否开启页面缓存
     */
    @Column(name = "keep_alive")
    private String keepAlive;

    /**
     * 【菜单】是否全屏(1:是 0:否)
     */
    @Column(name = "full")
    private String full;

    /**
     * 【菜单】是否固定tab不可关闭(1:是 0:否)
     */
    @Column(name = "affix")
    private String affix;
}
